package com.threeti.mecool.core.domain.model.plan.pojo;

public class UserRouteStep extends UserStep {
	@Override
	public Step getNextStep() {
		if (!isFinished()) {
			return getStep();
		}
		RouteStep routeStep = (RouteStep) getStep();
		long routeStepItemId = Long.parseLong(getUserTask().getTaskData());
		return routeStep.getItemByRouteStepItemId(routeStepItemId).getNextStep();
	}
	
	@Override
	public boolean isFinished() {
		UserTask userTask = getUserTask();
		if (userTask != null) {
			try {
				long routeStepItemId = Long.parseLong(userTask.getTaskData());
				RouteStep routeStep = (RouteStep) getStep();
				if (routeStep.getItemByRouteStepItemId(routeStepItemId) != null) {
					return true;
				}
			} catch (Exception e) {
				return false;
			}
		}
		return false;
	}
}
